/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vn.edu.thptduongbachmai.model;

import com.vng.zing.logger.ZLogger;
import hapax.TemplateDataDictionary;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import vn.edu.thptduongbachmai.common.TemplateManager;
import vn.edu.thptduongbachmai.services.DBService;
import vn.edu.thptduongbachmai.services.MySQLService;

/**
 * @Note: Class base model xử lý business chung & hàm tiện ích cho tất cả
 * handler/controller, các model chính được thừa kế từ base model này
 *
 * @author tiennv4
 */
public abstract class BaseModel {

    private static final Logger _Logger = ZLogger.getLogger(BaseModel.class);
    protected static final DBService CliMySQL = MySQLService.getInstance("BaseModel");

    public final void process(HttpServletRequest req, HttpServletResponse resp) {
        TemplateDataDictionary layout = prepareLayout();
        TemplateDataDictionary dic = prepareBody(layout);
        dic = pullData(dic,req);
        render(dic, resp);
    }

    public abstract TemplateDataDictionary prepareLayout();

    public abstract TemplateDataDictionary prepareBody(TemplateDataDictionary dic);

    public abstract TemplateDataDictionary pullData(TemplateDataDictionary dic,HttpServletRequest req);

    public abstract void render(TemplateDataDictionary dic, HttpServletResponse resq);
}
